home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / update / tpasc302.cpt / TCL Update / New More Files / CResFile.p < prev    next >
Encoding:
Text File  |  1990-05-11  |  1.8 KB  |  95 lines

  1. {****************************************************}
  2. {         CResFile.p}
  3. {}
  4. {        The Resource File Class}
  5. {}
  6. {        SUPERCLASS = CFile}
  7. {}
  8. {        Copyright ⌐ 1989, Symantec Corporation.  All rights reserved.            }
  9. {}
  10. {****************************************************}
  11.  
  12. unit CResFile;
  13.  
  14. interface
  15.  
  16.     uses
  17.         TCL, MoreTCL;
  18.  
  19. implementation
  20.  
  21.  
  22.  
  23. {*** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ***}
  24.  
  25.  
  26.  
  27. {****************************************************}
  28. { IResFile}
  29. {}
  30. {        Initialize a ResFile object}
  31. {}
  32. {****************************************************}
  33.  
  34.     procedure CResFile.IResFile;
  35.     begin
  36.         IFile;
  37.         refNum := 0;
  38.     end;
  39.  
  40.  
  41. {****************************************************}
  42. { Open (OVERRIDE)}
  43. {}
  44. {        Open the resource fork of a file with the specified access permission.}
  45. {        Opening the file automatically makes it the current resource file.}
  46. {}
  47. {****************************************************}
  48.  
  49.     function CResFile.Open (permission: SignedByte): OSErr;
  50.     begin
  51.  
  52.     { Altered by TCL Weaver 1.0 (5/11/90) }
  53.  
  54.         refNum := HOpenResFile(volNum, dirID, name, permission);
  55.  
  56.         if refNum = -1 then
  57.             refNum := 0;
  58.         Open := ResError;
  59.     end;
  60.  
  61.  
  62. {****************************************************}
  63. { Close (OVERRIDE)}
  64. {}
  65. {        Close a File and make sure contents are written to disk}
  66. {}
  67. {****************************************************}
  68.  
  69.     function CResFile.Close: OSErr;
  70.     begin
  71.         if refNum > 0 then
  72.             begin
  73.                 CloseResFile(refNum);
  74.                 refNum := 0;
  75.                 Close := FlushVol(nil, volNum);
  76.             end
  77.         else
  78.             Close := fnOpnErr;
  79.     end;
  80.  
  81.  
  82. {****************************************************}
  83. { MakeCurrent}
  84. {}
  85. {        Make this the current resource file}
  86. {}
  87. {****************************************************}
  88.  
  89.     procedure CResFile.MakeCurrent;
  90.     begin
  91.         UseResFile(refNum);
  92.     end;
  93.  
  94.  
  95. end.